<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('下级退回T-待处理')"/>
    <link th:href="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.css}" rel="stylesheet">
</head>
<style>
    .smsnote {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
    }
</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <div class="smsnote">
                                <label style="width: 150px;">是否开启驳回短信通知：</label>
                                <div style="margin-top: 5px;">
                                    <input type="checkbox" name="smsInform" th:checked="${smsInform} eq 1 ? true : false" th:value="${smsInform}">
                                </div>
                                <input type="hidden" name="optType" value="1">
                            </div>
                        </li>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <!--                TODO-->
            <a class="btn btn-success single disabled" onclick="handle()">
                <i class="fa"></i> 处理
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "gaoxin/system/mTelWF";
    var mInterior = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix + "/rCity/listSonNABackJson",
            sortName: "pkId",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            updateUrl: prefix+"/forShow/treturnReason/{id}",
            modalName: "下级退回工单",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'pkid',visible:false},
                {field:'twfpk',title:'twfpk',visible:false},
                {field:'telpk',title:'telpk',visible:false},
                {field:'fDNo',title:'fDNo',visible:false},
                {field:'WfId',title:'工单编号',align:'center',sortable:true,formatter:function(value,row,index){return fmtScanByNO(value,row,index);}},
                {field:'myTwfTopic',title:'工单主题',align:'left'},
                {field:'SBDeptName',title:'承办部门',align:'left',sortable:true},
                {field:'SeqName',title:'交办次序',align:'center'},
                {field:'SortName',title:'性质',align:'center',sortable:true},
                {field:'BackLimit',title:'办理期限',align:'center',sortable:true},
                {field:'SendRemark',title:'派发备注',align:'center',width:50,
                    formatter:function (value, row, index,field) {
                        if(value===undefined){
                            value='';
                        }
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'SAttachPath',title:'直派',align:'center',sortable:true,formatter:function(value,row,index){return fmtWFormZP(value,row,index);}},
                {field:'SendState',title:'签收情况',align:'center',sortable:true,formatter:function(value,row,index){return fmtSBSendState(value,row,index);}},
                {field:'BackState',title:'回复情况',align:'center',sortable:true,formatter:function(value,row,index){return fmtSBBackState(value,row,index);}},
                {field:'chgChk',title:'审查情况',align:'center',formatter:function(value,row,index){return fmtSBBackCheck(value,row,index);}},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="handle(\'' + row.myPkVal + '\')"><i class="fa"></i>处理</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function fmtScanByNO(value,row,index){
        var idtel = row.telpk; var idwf = row.twfpk;
        return '<a href="javascript:void(0);" onclick="OnQxListShowWin('+idwf+')" title="单击查看详情" class="lstWd">'+value+'</a>';
    }

    function OnQxListShowWin(idWF) {
        var url =  "gaoxin/system/test/caseDetail/"+idWF;
        var title = "电话工单详情";
        parent.$.modal.openTab(title, url);
    }

    function handle(pkId){
        if (!pkId) {
            var row = $("#bootstrap-table").bootstrapTable('getSelections');
            pkId = row[0].myPkVal;
        }
        var url = prefix+"/forShow/treturnReason/"+pkId;
        parent.$.modal.openTab('下级退回工单审核',url);
    }

    //是否开启短信通知
    $('[name="smsInform"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
            if (state === true) {
                $(this).val(1);
                $.modal.confirm("确认开启驳回短信通知？", function() {
                    $.operate.post("/smsNote/isNote", $('#post-form').serializeArray());
                })
            } else {
                $(this).val(0);
                $.modal.confirm("确认关闭驳回短信通知？", function() {
                    $.operate.post("/smsNote/isNote", $('#post-form').serializeArray());
                })
            }
        }
    });
</script>
</body>
</html>